<template>
  <div>
    <v-top></v-top>
    <button @click="$router.push('/register')">注册</button>
    <div class="form">
      <div>
        <img src="mobile\src\assets\img\54.gif" alt />
      </div>
      <div>
        <input type="text" placeholder="手机号" v-model="user.phone" />
        <br />
      </div>
      <div>
        <input type="text" placeholder="密码" v-model="user.password" />
        <br />
      </div>
      <div>
        <input type="button" value="登录" @click="login" />
        <br />
        <!-- <button @click="login">登录</button> -->
      </div>
    </div>
  </div>
</template>

<script>
// import axios from "axios"
import { reqLogin } from "../../http/api";
export default {
  data() {
    return {
      user: {
        phone: "",
        password: "",
      },
    };
  },
  methods: {
    login() {
      reqLogin(this.user).then((res) => {
        // console.log(res);
        if (res.data.code == 200) {
          //登录成功
          //设计一个标记
          localStorage.setItem("islogin", true);
          //存用户身份
          localStorage.setItem("type", this.type);
          //用户信息
          localStorage.setItem("user", JSON.stringify(res.data.list));
          this.$router.push("/index");
        }
      });
    },
  },
};
</script>

<style scoped>
img {
  width: 3.63rem;
  height: 0.96rem;
  margin: 0.5rem;
}
.form {
  width: 100vw;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
input {
  width: 80%;
  margin-top: 0.5rem;
}
button {
  width: 1rem;
  position: fixed;
  top: 0.3rem;
  right: 0.1rem;
}
</style>